package com.xinchuang.controller.targetSystem.damage;

import com.xinchuang.comment.R;
import com.xinchuang.common.Result;
import com.xinchuang.dto.DeleteDto;
import com.xinchuang.service.targetSystem.damage.THurtEvaluateService;
import com.xinchuang.vo.THurtEvaluateVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author lvjie
 * @program systems-analysis
 * @description HS评定标准
 * @date 2024/05/15
 */
@RestController
@RequestMapping("/tHurtEvaluate")
@Api(value = "HS评定标准", tags = "HS评定标准")
public class THurtEvaluateController {

    @Autowired
    private THurtEvaluateService tHurtEvaluateService;

    /**
     * 添加HS评定标准，一并完成主表毁伤评定标准基础表（t_hurt_evaluate_basic）
     * 和子表A毁伤评定标准关联表(毁伤评定与子目标)t_hurt_evaluate_sub
     * 子表B 毁伤评定标准关联表(弹型弹种关联)(t_hurt_evaluate_ammunition)
     *
     * @param tHurtEvaluateVo
     * @return
     */
    @PostMapping("/addAndUpdateHurtEvaluate")
    public Result addHurtEvaluate(@RequestBody THurtEvaluateVo tHurtEvaluateVo) {
        return tHurtEvaluateService.addAndUpdateHurtEvaluate(tHurtEvaluateVo);
    }

    /**
     * 删除/批量删除数据,一并完成主表毁伤评定标准基础表（t_hurt_evaluate_basic）
     * 和子表A毁伤评定标准关联表(毁伤评定与子目标)t_hurt_evaluate_sub
     * 子表B 毁伤评定标准关联表(弹型弹种关联)(t_hurt_evaluate_ammunition)
     *
     * @return
     */
    @DeleteMapping("/deleteHurtEvaluate")
    public R deleteHurtEvaluate(@RequestParam(value = "deleteStatus") boolean deleteStatus,
                                @RequestParam(value = "ids[]") String id) {
        tHurtEvaluateService.deleteHurtEvaluate(id, deleteStatus);
        return R.success("删除成功");
    }

    /**
     * 分页查询HS评定标准，一并返回主表毁伤评定标准基础表（t_hurt_evaluate_basic）
     * 和子表A毁伤评定标准关联表(毁伤评定与子目标)t_hurt_evaluate_sub
     * 子表B 毁伤评定标准关联表(弹型弹种关联)(t_hurt_evaluate_ammunition)
     *
     * @param pageSize         页包含数据条数
     * @param pageNum          第几页
     * @param targetTypeId     目标类别id
     * @param destroyLevel     破坏等级
     * @param targetTypeSubId  打击子目标id
     * @param typeOfAmmunition 弹型弹种id
     * @return
     */
    @GetMapping("/listHurtEvaluate")
    public R listHurtEvaluate(@RequestParam Integer pageSize,
                              @RequestParam Integer pageNum,
                              @RequestParam(required = false) String targetTypeId,
                              @RequestParam(required = false) String destroyLevel,
                              @RequestParam(required = false) String targetTypeSubId,
                              @RequestParam(required = false) String typeOfAmmunition
    ) {
        Map<String, Object> tTHurtEvaluateVoPage = tHurtEvaluateService.listHurtEvaluate(pageSize, pageNum, targetTypeId, destroyLevel, targetTypeSubId, typeOfAmmunition);
        return R.data(tTHurtEvaluateVoPage);
    }

}
